package org.example.rsy.service.impl;

import org.apache.tika.sax.boilerpipe.BoilerpipeContentHandler;
import org.example.rsy.service.BaseTikaService;
import org.springframework.stereotype.Service;
import org.xml.sax.ContentHandler;

import java.io.StringWriter;

@Service
public class MainContentTikaService extends BaseTikaService {

   private final StringWriter writer = new StringWriter();

    @Override
    public ContentHandler initHandler() {
        return new BoilerpipeContentHandler(writer);
    }

    @Override
    public String extractData() {
        String res = writer.toString();
        writer.getBuffer().setLength(0);
        return res;
    }

    @Override
    public int getCode() {
        return 4;
    }
}
